Use case: DMA channel linear linked-list mode transfer in polling mode

Note

To perform a DMA linked-list transfer, follow these steps:

  • First, fill the desired nodes with the required configuration.

  • Next, create a queue using these filled nodes.

  • Finally, start the transfer using the built queue.

Sequence diagram

Linked-list mode transfer in polling mode.

  @startuml
  hide footbox
  participant "User Application" as part1
  participant "DMA Driver"       as part3

  group Configuration
  part1->part3 : HAL_DMAEx_List_BuildNode()
  part1->part3 : HAL_DMAEx_List_InsertNode()
  part1->part3 : HAL_DMAEx_List_Init()
  end

  group Process
      group  Start
          part1->part3 : HAL_DMAEx_List_Start()
      end
      group  Polling for transfer
          part1->part3 : HAL_DMA_PollForTransfer()
          part3->part1:
      end
  end

  @enduml

Code snippet

HAL1

HAL2

HAL_DMAEx_List_BuildNode(&NodeConf, &Node1);

HAL_DMAEx_List_InsertNode(&Queue1, NULL, &Node1);


HAL_DMAEx_List_Init(&LL_HandleDMA1);


HAL_DMAEx_List_LinkQ(&LL_HandleDMA1, &Queue1);

HAL_DMAEx_List_Start(&LL_HandleDMA1)


HAL_DMA_PollForTransfer(&hdma_F, HAL_DMA_FULL_TRANSFER, timeout);
HAL_DMA_FillNodeConfig(Node1, NodeConf, HAL_DMA_NODE_2D_ADDRESSING);

HAL_Q_Init(Queue2, &HAL_DMA_2DAddressing_DescOps);
HAL_Q_InsertNode(Queue2, NULL, Node1);

HAL_DMA_Init(LL_DMA_Handle1, HAL_GPDMA1_CH12);
HAL_DMA_SetConfigLinkedListXfer(LL_DMA_Handle1, LL_xfer_config1);



HAL_DMA_StartLinkedListXfer(&hdma, srcAddress, dstAddress, dataSize * multiplier);


HAL_DMA_PollForXfer(&hdma, HAL_DMA_XFER_FULL_COMPLETE, timeout);

Key changes

  1. HAL2 introduces a queue-based approach using HAL_Q_* services for linked-list transfers.

  2. HAL2 configures linked-list transfers using HAL_DMA_SetConfigLinkedListXfer() and starts them using HAL_DMA_StartLinkedListXfer().

  3. HAL2 uses HAL_DMA_PollForXfer() for polling completion.